You can use the rendering extensions for Image, HTML, PDF, XML or Word to render a in any of the supported formats. See Rendering for details on rendering formats.
The following steps provide an example of rendering a report in the format.
- In Visual Studio, create a new Windows Forms Application or open an existing one containing a Page Report.
- Copy and place the Page Report in the project's Debug folder.
- On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
- Add the following code inside the Form_Load event.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
' Provide the page report you want to render.
Dim _reportDef As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("MovieRatings.rdlx"))
Dim _reportRuntime As New GrapeCity.ActiveReports.Document.PageDocument(_reportDef)
' Set the file format you want the report to be rendered in.
Dim FileName As String = Application.StartupPath + "\ActiveReports.pdf"
' Provide settings for your rendering output.
Dim settings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()
settings.HideToolbar = True
settings.HideMenubar = True
settings.HideWindowUI = True
' Set the rendering extension and render the report.
Dim _renderingExtension As New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension()
Dim _exportfile As FileStreamProvider = New FileStreamProvider(New DirectoryInfo(Path.GetDirectoryName(FileName)), Path.GetFileNameWithoutExtension(FileName))
_reportRuntime.Render(_renderingExtension, _exportfile, settings)
|
To write the code in C#
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
// Provide the page report you want to render.
GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"MovieRatings.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);
// Set the file format you want the report to be rendered in.
string FileName = Application.StartupPath + "\\ActiveReports.pdf";
// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Pdf.Page.Settings settings = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
settings.HideToolbar = true;
settings.HideMenubar = true;
settings.HideWindowUI = true;
// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension _renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
FileStreamProvider _exportfile = new FileStreamProvider(new DirectoryInfo(Path.GetDirectoryName(FileName)), Path.GetFileNameWithoutExtension(FileName));
_reportRuntime.Render(_renderingExtension, _exportfile, settings);
|
|
Note: The code above works for any supported rendering format. Simply, replace the instances of PDF with the specific rendering format type and use the desired rendering extension. |
|
Note: By default, the image rendering extension creates a separate file for each page in a report and adds an index to each corresponding file name (for example, image001.PNG, image002.PNG, etc).
To render the entire report as a single image, set the Pagination setting to False.
|
See Also